<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增公告信息')" />

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-notice-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">公告标题：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="noticeTitle" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">公告类别：</label>
            <div class="col-xs-10">
                <select id="type" class="form-control select2-multiple" multiple>
                    <option th:each="type:${types}" th:value="${type.typeId}" th:text="${type.typeName}" th:disabled="${type.typeId == '1'}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">公告内容：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="noticeDesc" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">开始日期：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="startDate" placeholder="yyyy-MM-dd" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">失效日期：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="endDate" placeholder="yyyy-MM-dd" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="remark" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">


    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var noticeTitle = $("input[name='noticeTitle']").val();
        var tId = $.form.selectSelects("type");
        var noticeDesc = $("input[name='noticeDesc']").val();
        var startDate = $("input[name='startDate']").val();
        var endDate = $("input[name='endDate']").val();
        var remark = $("input[name='remark']").val();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "notice/cnotice/add",
            data : {
                "noticeTitle": noticeTitle,
                "tId": tId,
                "noticeDesc": noticeDesc,
                "startDate": startDate,
                "endDate": endDate,
                "remark": remark
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
